<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        div{
            width: 300px;
            height: 100px;
            background-color: red;
            position: absolute;
            left:50%;
            top:100px;
        }
        div:nth-child(1){
            /*margin-left:-150px;*/
        }

        div:nth-child(2){
            top:300px;
            /* 水平方向上向左走自己宽度的一半*/
            /*推荐的写法*/
            transform:translate(-50%);
        }
    </style>
</head>
<body>
    <div></div>
    <div></div>
</body>
</html>